$(document).ready(function() {
	function fresh(element, str_t) {
		var past = false;
		var endtime = new Date(str_t);
		var nowtime = new Date();
		var leftsecond = parseInt((endtime.getTime() - nowtime.getTime())
				/ 1000);
		if (leftsecond < 0) {
			past = true;
			leftsecond = 0;
		}
		h = parseInt(leftsecond / 3600);
		m = parseInt((leftsecond / 60) % 60);
		s = parseInt(leftsecond % 60);
		if (past) {
			$(element).html("抢购时间已结束");
			return;
		}
		$(element).html(h + "小时" + m + "分" + s + "秒");
	}
	window.setInterval(function() {
				var dates = new Array("July 3, 2012 20:00:00",
						"June 20, 2012 10:54:00", "June 30, 2012 24:00:00",
						"July 3, 2012 8:00:00", "July 3, 2012 7:00:00");
				$("dd[id^=surplus_t]").each(function() {
							fresh(arguments[1], dates[arguments[0]]);
						})
			}, 1000);
});
